/*
 * @Description: 要货计划详情DS
 * @Version: 1.0
 * @Autor: c-jack.qian
 * @Date: 2020-12-29 18:00:30
 * @LastEditors: c-jack.qian
 * @LastEditTime: 2021-04-25 15:17:00
 */

import { FieldType } from 'choerodon-ui/pro/lib/data-set/enum';
import commonConfigStore from '@common/config/commonConfig';
import intl from 'utils/intl';
// const O2_CM = process.env.NODE_ENV === 'development' ? '/o2cp' : commonConfigStore.O2_CM;
const O2_OM = process.env.NODE_ENV === 'development' ? '/o2om-c' : commonConfigStore.O2_OM;

const requireGoodsPlanDtlDS = () => ({
    autoQuery: true,
    selection: 'multiple',
    primaryKey: 'id',
    transport: {
        read: config => {
            return {
                ...config,
                url: `${O2_OM}/v1/requirement-plans`,
                method: 'get',
            };
        },
        destroy: config => {
            return {
                ...config,
                url: `${O2_OM}/v1/quota-plans`,
                method: 'delete',
            };
        },
    },
    fields: [
        {
            name: 'planMonth',
            type: FieldType.month,
            label: intl.get('dji.otc.om.view.field.planMonth').d('月份'),
        },
        {
            name: 'shortageType',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.shortageType').d('类型'),
        },
        {
            name: 'version',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.version').d('版本'),
        },
        {
            name: 'planStatusCode',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.checkRuleStatusCode').d('状态'),
            lookupCode: 'DJISM.REQUIREMENT_PLAN_STATUS',
        },
        {
            name: 'regionName',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.region').d('大区'),
        },
        {
            name: 'areaName',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.area').d('小区'),
        },
        {
            name: 'businessGroup',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.channel').d('渠道'),
        },
        {
            name: 'customerName',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.customerName').d('客户'),
        },
        {
            name: 'retailer',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.retailer').d('零售商'),
        },
        {
            name: 'productCode',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.productCode').d('料号'),
        },
        {
            name: 'productName',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.productName').d('产品名称'),
        },
        {
            name: 'quantityFirstWeek',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.quantityFirstWeek').d('T+1 WK1'),
        },
        {
            name: 'quantitySecondWeek',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.endDate').d('T+1 WK2'),
        },
        {
            name: 'quantityThirdWeek',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.quantityThirdWeek').d('T+1 WK3'),
        },
        {
            name: 'quantityFourthWeek',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.quantityFourthWeek').d('T+1 WK4'),
        },
        {
            name: 'quantityFifthWeek',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.quantityFifthWeek').d('T+2 WK1'),
        },
        {
            name: 'quantitySixthWeek',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.quantitySixthWeek').d('T+2 WK2'),
        },
        {
            name: 'quantitySeventhWeek',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.quantitySeventhWeek').d('T+2 WK3'),
        },
        {
            name: 'quantityEighthWeek',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.quantityEighthWeek').d('T+2 WK4'),
        },
        {
            name: 'quantityThirdMonth',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.quantityThirdMonth').d('T+3'),
        },
        {
            name: 'quantityFourthMonth',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.quantityFourthMonth').d('T+4'),
        },
        {
            name: 'quantityFifthMonth',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.quantityFifthMonth').d('T+5'),
        },
        {
            name: 'quantitySixthMonth',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.quantitySixthMonth').d('T+6'),
        },
        {
            name: 'importantProject',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.importantProject').d('重大项目'),
        },
        {
            name: 'memo',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.memo').d('备注'),
        },
    ],
    queryFields: [
        {
            name: 'customerName',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.agentName').d('代理商'),
        },
        {
            name: 'productName',
            type: FieldType.string,
            label: intl.get('dji.otc.om.view.field.productName').d('产品'),
        },
        {
            name: 'regionId',
            type: FieldType.number,
            label: intl.get('dji.otc.om.view.field.region').d('大区'),
            lookupCode: 'DJICM_CHOOSE_BIG_AREA',
        },
        {
            name: 'areaId',
            type: FieldType.number,
            label: intl.get('dji.otc.om.view.field.area').d('小区'),
            lookupCode: 'DJIOM_CHOOSE_SMALL_AREA',
        },
        {
            label: intl.get('dji.otc.om.view.field.customerType').d('客户类型'),
            name: 'customerType',
            type: FieldType.string,
            lookupCode: 'DJISM.CUSTOMER_TYPE'
        },
    ],
});

// 产销确认ds
const productMakeDS = () => ({
    dataToJSON: 'normal',
    transport: {
        submit: config => {
            return {
                ...config,
                url: `${O2_OM}/v1/requirement-plans/production-and-marketing-confirm`,
                method: 'POST',
            };
        },
    },
});

// 大区确认DS
const bigAreaMakeDS = () => ({
    dataToJSON: 'normal',
    transport: {
        submit: config => {
            return {
                ...config,
                url: `${O2_OM}/v1/requirement-plans/theater-confirm`,
                method: 'POST',
            };
        },
    },
});

export { requireGoodsPlanDtlDS, productMakeDS, bigAreaMakeDS };
